package com.sais.common.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;

/**
 * <p>
 * 类型转换工具类
 * </p>
 *
 * @author zwp
 * @since 2019/5/31
 */
@Slf4j
public class ConvertObjUtils {

    private ConvertObjUtils() {
    }

    public static <T> T convert(Object source, Class<T> clazz) {
        T t = null;
        try {
            t = clazz.newInstance();
        } catch (InstantiationException e) {
            log.error("{}", e);
        } catch (IllegalAccessException e) {
            log.error("{}", e);
        }
        BeanUtils.copyProperties(source, t);
        return t;
    }

}
